//
//  HYOUHeadDetailView.m
//  BestGift
//
//  Created by 温晓宇 on 16/1/13.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "HYOUHeadDetailView.h"
#import "HYOUHeadDetailCell.h"
@interface HYOUHeadDetailView ()<UITableViewDataSource, UITableViewDelegate>

@property(nonatomic ,retain) HYOUBaseTableView *myTableView;

@end

@implementation HYOUHeadDetailView
//-(void)dealloc{
//    [_bigArray release];
//    [_delegate release];
//    [_myTableView release];
//    [super dealloc];
//}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubViews];
    }
    return self;
}
-(void)createSubViews{
    self.myTableView = [[HYOUBaseTableView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT - 64) style:UITableViewStylePlain];
    self.myTableView.delegate = self;
    self.myTableView.dataSource = self;
    [self addSubview:self.myTableView];
//    [_myTableView release];
    
    [self.myTableView registerClass:[HYOUHeadDetailCell class] forCellReuseIdentifier:@"cell"];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.bigArray.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    HYOUHeadDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    cell.model = [self.bigArray objectAtIndex:indexPath.row];
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 150;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    HYOUOneCellModel *model = [self.bigArray objectAtIndex:indexPath.row];
    [self.delegate showHeadDetailWeb:model.content_url Image:model.cover_image_url title:model.title];
    NSLog(@"%@",model.url);
}
-(void)setBigArray:(NSMutableArray *)bigArray{
    if (_bigArray != bigArray) {
        [_bigArray release];
        _bigArray = [bigArray retain];
    }
    [self.myTableView reloadData];
}

@end
